<!-- Util tag library documentation
  -  Copyright (C) 2012 Stephane Carrez
  -  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
  -
  -  Licensed under the Apache License, Version 2.0 (the "License");
  -  you may not use this file except in compliance with the License.
  -  You may obtain a copy of the License at
  -
  -      http://www.apache.org/licenses/LICENSE-2.0
  -
  -  Unless required by applicable law or agreed to in writing, software
  -  distributed under the License is distributed on an "AS IS" BASIS,
  -  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  -  See the License for the specific language governing permissions and
  -  limitations under the License.
  -->
<c:choose xmlns:c="http://java.sun.com/jstl/core"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:util="http://code.google.com/p/ada-asf/util">
    <!-- For security reasons, check that the code parameter matches what is allowed  -->

    <c:when test="#{empty param['code'] or param['code'] eq 'escape'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:escape"/>
            <ui:define name="description">
                Render the inner component children and escape the resulting HTML text using
                Javascript escape rules.  Using the <b>util:escape</b> component is useful
                when rendering a Javascript extract or a Json response.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>rendered</b>
                    <i>Boolean</i>
                    <span>Flag indicating whether or not this component should be rendered (during Render Response Phase),
                        or processed on any subsequent form submit. The default value for this property is true.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'file'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:file"/>
            <ui:define name="description">
                This component allows to include an external file in the render response phase.

            </ui:define>
            <ui:define name="attributes">
                <li class="attr-required">
                    <b>src</b>
                    <i>String</i>
                    <span>The relative path for the file to be included.</span>
                </li>
                <li class="attr-optional">
                    <b>rendered</b>
                    <i>Boolean</i>
                    <span>Flag indicating whether or not this component should be rendered (during Render Response Phase),
                        or processed on any subsequent form submit. The default value for this property is true.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'flush'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:flush"/>
            <ui:define name="description">
                This component is used in the render response phase only.
                It flushes the javascript code that has been queued either by some component
                or by the <b>util:script</b> tag.  This allows to flush the javascript at
                well known places.  When <b>response</b> is specified and true, it also
                flushes the response stream.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>response</b>
                    <i>Boolean</i>
                    <span>Flag indicating whether the response stream must be flushed.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'param'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:param"/>
            <ui:define name="description">
                Defines a parameter.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-required">
                    <b>name</b>
                    <i>String</i>
                    <span>The parameter name.</span>
                </li>
                <li class="attr-required">
                    <b>value</b>
                    <i>ValueExpression</i>
                    <span>The parameter value.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'script'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:script"/>
            <ui:define name="description">
                In the render response phase, queue some javascript code in the response stream.
                The javascript code is automatically flushed before sending the response stream.
                It can be flushed explicitly by using the <b>util:flush</b> component.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>rendered</b>
                    <i>Boolean</i>
                    <span>Flag indicating whether or not this component should be rendered (during Render Response Phase),
                        or processed on any subsequent form submit. The default value for this property is true.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>
    <c:when test="#{param['code'] eq 'view'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:view"/>
            <ui:define name="description">
                Create a root view component.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-required">
                    <b></b>
                    <i></i>
                    <span>No attributes defined</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:otherwise>
        <p>
            <h:outputFormat value="You have not selected the valid code: '{0}' is not recognized.">
                <f:param value="#{param['code']}"/>
            </h:outputFormat>
        </p>
    </c:otherwise>
</c:choose>